package com.murfrosoft.views;


import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PointF;



public class AnimationView extends AnimationViewAbstractBase {


	int radius=10;
	PointF pointF;
	Float velocityX;
	Float velocityY;
	
	Thread thread;
	
	public AnimationView(Context context) {
		super(context);
		pointF=new PointF(100,100);
		velocityX=3f;
		velocityY=3f;
		
	
		// TODO Auto-generated constructor stub
	}

	@Override
	public void updatePhysics(){
		// update position
		pointF.x+=velocityX;
		pointF.y+=velocityY;
		
		// Michael is going to improve on this bounce!
		if( (pointF.x + velocityX) >= (530 - radius) || (pointF.x + velocityX) <= radius){
			velocityX = velocityX * (-1);
			radius++;
		}
		if( (pointF.y + velocityY) >= (840 - radius) || (pointF.y + velocityY) <= radius){
			velocityY = velocityY * (-1);
			radius++;
		}
		
		if( radius >= 90 ){
		    radius = 10;
		}
		
	}


	@Override
	public void draw(Canvas canvas) {
		 canvas.drawColor(Color.BLACK);
		 Paint paint = new Paint();
		 
		 // change color based on x-coordinate
		 paint.setColor(Color.rgb((int)(pointF.x/2),(int)(pointF.x/2),(int)(pointF.x/2)));
		 
		 //if( radius%2 == 0 ){
		 //	 paint.setColor(Color.MAGENTA);
		 //}
		 //else{
		 //	 paint.setColor(Color.YELLOW);
		 //}
		 //else{
		 //paint.setColor(Color.RED);
		 //}
		 canvas.drawCircle(pointF.x, pointF.y, radius, paint);
		
	}

}
